﻿using BigEgg.Framework.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnitTestDemo.Applications.Humans;

namespace UnitTestDemo.Applications.Test.Humans
{
    [TestClass]
    public class HumanTest
    {
        [TestMethod]
        public void GeneralHumanTest()
        {
            Human human = new Human("BigEgg");
            Assert.AreEqual("Human", human.AnimalType);
            Assert.AreEqual("BigEgg", human.Name);
            Assert.IsNotNull(human.Contacts);
            Assert.AreEqual(0, human.Contacts.Count);
            Assert.AreEqual(string.Empty, human.Output);

            human.Contacts.Add(new ContactInfo()
            {
                Type = "Uri",
                Value = @"https://unittestdemo.codeplex.com/"
            });
            Assert.AreEqual(1, human.Contacts.Count);

            Assert.IsTrue(human.CanRead());
            human.Read("Read Something.");
            Assert.AreEqual("Read Something.", human.Output);
        }

        [TestMethod]
        public void PropertiesWithNotification()
        {
            Human human = new Human("BigEgg");

            AssertHelper.PropertyChangedEvent(human, x => x.Output, () => human.Read("Read Something."));
            Assert.AreEqual("Read Something.", human.Output);
        }

        [TestMethod]
        public void CleanDirtyContactsTest()
        {
            Human human = new Human("BigEgg");

            human.Contacts.Add(new ContactInfo()
            {
                Type = "Uri",
                Value = @"https://unittestdemo.codeplex.com/"
            });
            human.Contacts.Add(new ContactInfo()
            {
                Type = "phone",
                Value = ""
            });
            Assert.AreEqual(2, human.Contacts.Count);

            human.CleanDirtyContacts();
            Assert.AreEqual(1, human.Contacts.Count);
        }
    }
}
